﻿using Ardalis.Specification;
using Domain.Entities.Customers;

namespace NM.Module.Cust.API.Specifications;

#nullable disable

public class CustomerAdvancedPaginationSpec : Specification<Customer>
{
    public CustomerAdvancedPaginationSpec(CustomerAdvancedFilter filter)
    {
        Query
            .Where(x => x.Username.Contains(filter.Keyword) || x.Email.Contains(filter.Keyword), !string.IsNullOrWhiteSpace(filter.Keyword))
            .Where(x => x.Username == filter.Username, !string.IsNullOrWhiteSpace(filter.Username))
            .Where(x => x.Email == filter.Email, !string.IsNullOrWhiteSpace(filter.Email));
    }
}